package remote.skins
{
	import flash.display.BitmapData;
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	
	import remote.controls.Component;

	public class ImageSkin extends SkinBase implements ISkin
	{
		private var _image:DisplayObject;
		
		public function ImageSkin()
		{
			super();
		}
		
		public function draw(target:Component):void
		{
			if(_image == null)
				return;
			var bmpData:BitmapData = new BitmapData(target.width, target.height, true, 0);
			var s:Sprite = new Sprite();
			_image.width = target.width;
			_image.height = target.height;
			s.addChild(_image);
			bmpData.draw(s);
			target.graphics.clear();
			target.graphics.beginBitmapFill(bmpData);
			target.graphics.drawRect(0, 0, target.width, target.height);
			target.graphics.endFill();
		}

		public function get image():DisplayObject
		{
			return _image;
		}

		public function set image(value:DisplayObject):void
		{
			_image = value;
		}

	}
}